import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSDEDataImportItem } from '../../dataentity/dataimport/ipsdedata-import-item';
import { IPSModelObject } from '../../ipsmodel-object';
import { PSModelServiceProxyImpl } from '../../psmodel-service-proxy-impl';

/**
 * 全局默认通用代理
 *
 * @author chitanda
 * @date 2021-06-08 20:06:55
 * @export
 * @class PSDEDataImportItemServiceProxy
 * @extends {PSModelServiceProxyImpl}
 */
export class PSDEDataImportItemServiceProxy extends PSModelServiceProxyImpl {
  getPSModel4(
    relatedPSModelObject: IPSModelObject,
    cls: string,
    objNode: any,
    strTag: string,
  ): IPSModelObject {
    switch (strTag) {
      case 'getPSAppDEField':
        return this.getPSAppDEField(
          relatedPSModelObject as IPSDEDataImportItem,
          objNode,
        );
    }
    return this.getRealPSModelService().getPSModel4(
      relatedPSModelObject,
      cls,
      objNode,
      strTag,
    );
  }

  getPSAppDEField(r: IPSDEDataImportItem, obj: any): any {
    const p = this.getParentPSModelObject(
      r,
      'app.dataentity.IPSAppDataEntity',
    ) as IPSAppDataEntity;
    if (p) {
      return p.findPSAppDEField(obj);
    }
    return null;
  }
}
